//
//  DGDownloadManager.h
//  DGDownloader
//
//  Created by Jinxiao on 4/15/16.
//  Copyright © 2016 debugeek. All rights reserved.
//

#import <Foundation/Foundation.h>

@class DGDownloadTask;
@class DGDownloadManager;

@protocol DGDownloadManagerDelegate <NSObject>

- (void)downloadManager:(DGDownloadManager *)downloadManager didStartDownloadTask:(DGDownloadTask *)downloadTask;

- (void)downloadManager:(DGDownloadManager *)downloadManager didFinishDownloadTask:(DGDownloadTask *)downloadTask;

- (void)downloadManager:(DGDownloadManager *)downloadManager didProcessDownloadTask:(DGDownloadTask *)downloadTask receivedBytes:(NSUInteger)receivedBytes totalBytes:(NSUInteger)totalBytes;

@end

@interface DGDownloadManager : NSObject

+ (instancetype)sharedInstance;

#pragma mark - Observer

- (void)addDownloadObserver:(id<DGDownloadManagerDelegate>)observer forIdentifier:(NSString *)identifier;
- (void)removeDownloadObserver:(id<DGDownloadManagerDelegate>)observer forIdentifier:(NSString *)identifier;

- (BOOL)enqueueDownloadTask:(DGDownloadTask *)downloadTask;

@end
